home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / MiniGames / JFS / JellyFishSwarmMG.as next >
Encoding:
Text File  |  2013-04-24  |  3.0 KB  |  106 lines

  1. class MiniGames.JFS.JellyFishSwarmMG extends MiniGames.BaseMiniGame
  2. {
  3.    var nNbJellyFish;
  4.    var oPatrick;
  5.    var mcRef;
  6.    var aJellyFishes;
  7.    var sState;
  8.    var bOver;
  9.    static var sSTATE_NORMAL = "Normal";
  10.    static var sSTATE_WHACKY = "Whacky";
  11.    static var nMAX_TIME = 24;
  12.    static var nSECOND_VALUE = 100;
  13.    static var nBUFFER_TIME = 10;
  14.    function JellyFishSwarmMG(_mcRef)
  15.    {
  16.       super(_mcRef);
  17.       this.nNbJellyFish = 0;
  18.       this.showInstructions();
  19.    }
  20.    function initMiniGame()
  21.    {
  22.       this.oPatrick = new MiniGames.JFS.JFSPatrick(this.mcRef.mcState.mcPatrick);
  23.       this.aJellyFishes = new Array();
  24.       for(var i in this.mcRef.mcState.mcContainer)
  25.       {
  26.          this.aJellyFishes.push(new MiniGames.JFS.JFSJellyFish(this.mcRef.mcState.mcContainer[i],this));
  27.          this.nNbJellyFish = this.nNbJellyFish + 1;
  28.       }
  29.    }
  30.    function setState(_sState)
  31.    {
  32.       super.setState(_sState);
  33.       if(this.sState == MiniGames.BaseMiniGame.sSTATE_MINIGAME || this.sState == MiniGames.BaseMiniGame.sSTATE_VICTORY)
  34.       {
  35.          if(Main.getRef().isCheatClothesActivated())
  36.          {
  37.             this.mcRef.mcState.gotoAndStop(MiniGames.JFS.JellyFishSwarmMG.sSTATE_WHACKY);
  38.          }
  39.          else
  40.          {
  41.             this.mcRef.mcState.gotoAndStop(MiniGames.JFS.JellyFishSwarmMG.sSTATE_NORMAL);
  42.          }
  43.       }
  44.       else if(Main.getRef().isCheatClothesActivated())
  45.       {
  46.          this.mcRef.mcBack.gotoAndStop(MiniGames.JFS.JellyFishSwarmMG.sSTATE_WHACKY);
  47.       }
  48.       else
  49.       {
  50.          this.mcRef.mcBack.gotoAndStop(MiniGames.JFS.JellyFishSwarmMG.sSTATE_NORMAL);
  51.       }
  52.    }
  53.    function doUnPause()
  54.    {
  55.       super.doUnPause();
  56.       this.mcRef.stop();
  57.       this.mcRef.mcBack.stop();
  58.       if(this.sState == MiniGames.BaseMiniGame.sSTATE_MINIGAME || this.sState == MiniGames.BaseMiniGame.sSTATE_VICTORY)
  59.       {
  60.          this.mcRef.mcState.stop();
  61.       }
  62.    }
  63.    function validateEndMiniGame()
  64.    {
  65.       if(this.nNbJellyFish == 0 && this.sState == MiniGames.BaseMiniGame.sSTATE_MINIGAME)
  66.       {
  67.          this.setVictory();
  68.       }
  69.    }
  70.    function destroyMiniGame()
  71.    {
  72.       super.destroyMiniGame();
  73.       for(var i in this.aJellyFishes)
  74.       {
  75.          this.aJellyFishes[i].cleanUp();
  76.       }
  77.       this.oPatrick.cleanUp();
  78.    }
  79.    function calculateScore()
  80.    {
  81.       this.addScoreFromTimeLeft(MiniGames.JFS.JellyFishSwarmMG.nMAX_TIME,MiniGames.JFS.JellyFishSwarmMG.nSECOND_VALUE);
  82.    }
  83.    function decreaseJellyFishCount()
  84.    {
  85.       if(this.nNbJellyFish > 0)
  86.       {
  87.          this.nNbJellyFish = this.nNbJellyFish - 1;
  88.       }
  89.    }
  90.    function takeHook(_oJelly)
  91.    {
  92.       this.oPatrick.takeHook(_oJelly);
  93.    }
  94.    function MiniGame()
  95.    {
  96.       super.MiniGame();
  97.    }
  98.    function Victory()
  99.    {
  100.       if(this.mcRef.mcState.mcState._currentframe == this.mcRef.mcState.mcState._totalframes - MiniGames.JFS.JellyFishSwarmMG.nBUFFER_TIME)
  101.       {
  102.          this.bOver = true;
  103.       }
  104.    }
  105. }
  106.